package mfuny.ggongal.admin;

import mfuny.ggongal.admin.event.EventDao;
import mfuny.ggongal.admin.event.EventService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class EventController {
    ModelAndView mav;
    EventService es;
    
    public EventController() throws Exception {
        mav = new ModelAndView();  
        es = new EventService();
    }
    
    @RequestMapping("/regEventForm.ga")
    public ModelAndView regEventForm() throws Exception {
        mav.clear();
        mav.setViewName("/event/regEventForm.ga");
        return mav;
    }
    
    @RequestMapping("/regEvent.ga")
    public ModelAndView regEvent(@ModelAttribute EventDao ev) throws Exception {
        return es.regEvent(ev);
    }
    
    @RequestMapping("/eventList.ga")
    public ModelAndView eventList() throws Exception {
    	return es.eventList();
    }
    
    @RequestMapping("/getEventList.ga")
    public ModelAndView getEventList(int num, int pageSize) throws Exception {
    	return es.getEventList(num, pageSize);
    }
    
    @RequestMapping("/deleteEvent.ga")
    public ModelAndView deleteEvent(int ev_no) throws Exception {
    	return es.deleteEvent(ev_no);
    }
    
    @RequestMapping("/modifyEventForm.ga")
    public ModelAndView modifyEventForm(int ev_no) throws Exception {
    	return es.modifyEventForm(ev_no);
    }
    
    @RequestMapping("/modifyEvent.ga")
    public ModelAndView modifyEvent(@ModelAttribute EventDao ev) throws Exception {
    	return es.modifyEvent(ev);
    }

}
